<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>订单管理</title>
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/css/bootstrap.min.css" />
<script src="${pageContext.request.contextPath}/js/jquery-3.2.1.min.js"></script>
<script src="${pageContext.request.contextPath}/js/bootstrap.min.js"></script>
</head>
<body>
	<!-- 头部信息 -->
	<jsp:include page="header.jsp"></jsp:include>

	<!-- 搜索区 -->
	<jsp:include page="order-search.jsp"></jsp:include>

	<!-- 内容区域 -->
	<div class="container-fluid" style="margin: 30px;">
		<div
			style="border: 1px solid gray; border-radius: 8px; height: 400px;">
			<!-- 订单列表 -->
			<div>
				<h3 style="text-align: center;">订单列表</h3>
				<table class="table">
					<thead>
						<tr>
							<th>订单编号</th>
							<th>用户id</th>
							<th>用户名</th>
							<th>创建时间</th>
							<th>订单状态</th>
							<th>操作</th>
						</tr>
					</thead>
					<tbody>
						<c:forEach items="${pageInfo.list}" var="order">
							<tr>
								<td><a href="${pageContext.request.contextPath}/order/findById.do?orderId=${order.orderId}">${order.orderId}</a></td>
								<td>${order.user.id}</td>
								<td>${order.user.username}</td>
								<td>${order.time}</td>
								<td>${order.statusStr}</td>
								<c:if test="${order.status==1}">
									<td><button type="button" class="btn btn-primary" disabled>已发货</button></td>
								</c:if>
								<c:if test="${order.status==0}">
									<td><button type="button" class="btn btn-primary" onclick="location.href='${pageContext.request.contextPath}/order/updateStatus.do?orderId=${order.orderId}'">发货</button></td>
								</c:if>
							</tr>
						</c:forEach>
					</tbody>
				</table>
			</div>
		</div>

				<!-- 分页 -->
			<div class="col-md-offset-5">
				<nav aria-label="Page navigation">
				<ul class="pagination">
					<c:if test="${pageInfo.pageNum==1}">
						<li class="disabled"><a href="#" aria-label="Previous"> <span
							aria-hidden="true">&laquo;</span>
					</a></li>
					</c:if>
					
					<c:if test="${pageInfo.pageNum!=1}">
						<li><a href="${pageContext.request.contextPath}/order/findAll.do?pageNum=${pageInfo.pageNum-1}&condition=${condition}" aria-label="Previous"> <span
							aria-hidden="true">&laquo;</span>
					</a></li>
					</c:if>

					<c:forEach begin="1" end="${pageInfo.pages}" var="i">
						<c:if test="${pageInfo.pageNum!=i}">
							<li><a
								href="${pageContext.request.contextPath}/order/findAll.do?pageNum=${i}&condition=${condition}">${i}</a></li>
						</c:if>
						<c:if test="${pageInfo.pageNum==i}">
							<li class="active"><a
								href="${pageContext.request.contextPath}/order/findAll.do?pageNum=${i}&condition=${condition}">${i}</a></li>
						</c:if>
					</c:forEach>
					
					<c:if test="${pageInfo.pageNum==pageInfo.pages}">
						<li class="disabled"><a aria-label="Next"> <span
							aria-hidden="true">&raquo;</span>
					</a></li>
					</c:if>
					
					<c:if test="${pageInfo.pageNum!=pageInfo.pages}">
						<li><a href="${pageContext.request.contextPath}/order/findAll.do?pageNum=${pageInfo.pageNum+1}&condition=${condition}" aria-label="Next"> <span
							aria-hidden="true">&raquo;</span>
					</a></li>
					</c:if>
				</ul>
				 <h4> 共${pageInfo.pages}条记录，共${pageInfo.total}页</h4>
			</nav>
			</div>
	</div>
</body>
</html>
